from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class Base():
    def __init__(self):

        self.driver = None
        cap={
            "platformName": "Android",
            "deviceName": "127.0.0.1:7555",
            "noReset": True,
            "appPackage": "com.xiachufang",
            "appActivity": "com.xiachufang.activity.home.HomeActivity"
        }
        self.driver.webdriver.Return('http:127.0.0.1:4723/wd/hub',cap)
    #找元素
    def find_ele(self,loc):
        ele=self.driver.webdriver(loc)
        return ele
    #显示等待找元素
    def findwait(self,loc):
        ele=WebDriverWait(self.driver,20).until(EC.element_to_be_clickable(loc))
    #滑动
    def huadong(self,a,b,c,d):
        self.driver.swit(a,b,c,d,20)
    #轻敲
    def qingqiao(self,x,y):
        self.driver.tap([x,y],200)
    #退出
    def tuichu(self):
        self.driver.quit()
    #截屏
    def jieping(self,a):
        self.driver.splec(a)


